package com.taplinker.client.im.rpc;

import com.taplinker.client.im.protocol.TapLinkerConversation;
import com.taplinker.client.im.rpc.body.Cmd004Rep;
import com.taplinker.client.im.rpc.body.ConvertUtil;
import com.taplinker.client.im.util.IMLogUtil;
import com.taplinker.core.rpc.Result;
import com.taplinker.core.util.json.JsonUtil;

public class Cmd016 extends SimpleSocketCommand<String> {
	private String id;
	
	private IMListener im;
	public Cmd016(String conversationId,IMListener callBack) {
		id = conversationId;
		im = callBack;
	}
	
	@Override
	public void yes(Result result) {
		IMLogUtil.log("016", id);
		
		Cmd004Rep value = JsonUtil.jsonToObject(((IMMessageResponse) result.object).getMessage().getBody(), Cmd004Rep.class);
		
		TapLinkerConversation conversation = ConvertUtil.convertToConversation(value);
		im.handleMessage(conversation);
	}

	@Override
	protected String getBody() {
		return id;
	}
	
	@Override
	protected String getCommand() {
		return "016";
	}
}
